home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 September / september_2000.iso / intercd / root / ^Linux / cdrecord-1.8.1 / lib / sprintf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-05  |  1.5 KB  |  66 lines

  1. /* @(#)sprintf.c    1.12 98/09/05 Copyright 1985 J. Schilling */
  2. /*
  3.  *    Copyright (c) 1985 J. Schilling
  4.  */
  5. /*
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2, or (at your option)
  9.  * any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; see the file COPYING.  If not, write to
  18.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. #include <mconfig.h>
  22. #include <vadefs.h>
  23. #include <standard.h>
  24.  
  25. /*
  26.  * Do not include stdio.h, BSD systems define sprintf the wrong way!
  27.  */
  28. EXPORT    int sprintf __PR((char *, const char *, ...));
  29.  
  30. #ifdef    PROTOTYPES
  31. static void _cput(char c, long ba)
  32. #else
  33. static void _cput(c, ba)
  34.     char    c;
  35.     long    ba;
  36. #endif
  37. {
  38.     *(*(char **) ba)++ = c;
  39. }
  40.  
  41. /* VARARGS2 */
  42. #ifdef    PROTOTYPES
  43. int sprintf(char *buf, const char *form, ...)
  44. #else
  45. int sprintf(buf, form, va_alist)
  46.     char    *buf;
  47.     char    *form;
  48.     va_dcl
  49. #endif
  50. {
  51.     va_list    args;
  52.     int    cnt;
  53.     char    *bp = buf;
  54.  
  55. #ifdef    PROTOTYPES
  56.     va_start(args, form);
  57. #else
  58.     va_start(args);
  59. #endif
  60.     cnt = format(_cput, (long)&bp, form,  args);
  61.     va_end(args);
  62.     *bp = '\0';
  63.  
  64.     return (cnt);
  65. }
  66.